import time,random


class role():
    def __init__(self,name = '【角色】'):
        self.name = name
        self.life = random.randint(100,150)
        self.fight = random.randint(30,50)

class robotA(role):
    def __init__(self,name = '【robotA】'):
        role.__init__(self,name)
        self.life = self.life * 5
        self.fight = self.fight * 3

    def fight_buff(self,opponent):
        if opponent.name == robotB:
            self.fight = self.fight * 1.5

class robotB(role):
    def __init__(self, name = '【robotB】'):
        role.__init__(self,name)
        self.life = self.life * 3
        self.fight = self.fight * 5

    def fight_buff(self,opponent):
        if opponent.name == robotC:
            self.fight = self.fight * 1.5

class robotC(role):
    def __init__(self, name = '【robotC】'):
        role.__init__(self,name)
        self.life = self.life * 4
        self.fight = self.fight * 4

    def fight_buff(self,opponent):
        if opponent.name == robotD:
            self.fight = self.fight * 1.5

class robotD(role):
    def __init__(self, name = '【robotD】'):
        role.__init__(self,name)
        self.life = self.life * 4
        self.fight = self.fight * 5

    def fight_buff(self,opponent):
        if opponent.name == robotE:
            self.fight = self.fight * 1.5

class robotE(role):
    def __init__(self, name='【robotE】'):
        role.__init__(self, name)
        self.life = self.life * 5
        self.fight = self.fight * 4

    def fight_buff(self,opponent):
        if opponent.name == robotF:
            self.fight = self.fight * 1.5

class robotF(role):
    def __init__(self, name = '【robotF】'):
        role.__init__(self,name)
        self.life = self.life * 8
        self.fight = self.fight * 5

    def fight_buff(self,opponent):
        if opponent.name == robotA:
            self.fight = self.fight * 1.5


class game:
    def __init__(self):
        self.players = []
        self.computer = []
        self.dict_players = {}

        self.score = 0

        self.make_role()
        self.start_game()
        self.show_role()
        self.order_role()
        self.pk_role()
        self.result_role()


    def make_role(self):
        for i in range(3):
            self.players.append(random.choice([robotA(),robotB(),robotC(),robotD(),robotE(),robotF()]))
            self.computer.append(random.choice([robotA(),robotB(),robotC(),robotD(),robotE(),robotF()]))

    def start_game(self):
        print('------------ 欢迎来到“PK小游戏” ------------')
        print('将自动生成【你的队伍】和【敌人队伍】')
        input('请按回车键继续。')

    def show_role(self):
        print('--------------------【游戏开始】--------------------')
        print('角色信息：')
        for i in range (3):

            print('【我方】：%s，攻击力：%d，血量：%d' %(self.players[i].name,self.players[i].fight,self.players[i].life))
        print('----------------------------------------')


        for i in range(3):
            print('【敌方】：%s，攻击力：%d，血量：%d' %(self.computer[i].name,self.computer[i].fight,self.computer[i].life))

        print('----------------------------------------')
        input('请按Enter键继续！')

    def order_role(self):

        for i in range(3):
            order = int(input('你想把【%s】放在第几个出厂?（请输入数字1-3）：'%self.players[i].name))
            self.dict_players[order] = self.players[i]
        print('')

        self.players = []

        for j in range(1,4):
            self.players.append(self.dict_players[j])

        for k in range(len(self.players)):
            print('我方出场顺序为：%s' %self.players[k].name,end='、')
        print('')
        for l in range(len(self.computer)):
            print('敌方出场顺序为：%s' %self.computer[l].name,end='、')
        print('')

        print('----------------------------------------')
        input('请按Enter键继续！')


    def pk_role(self):

        for i in range(3):

            self.players[i].fight_buff(self.computer[i])
            self.computer[i].fight_buff(self.players[i])

            print('--------------------【第%s局】--------------------' %(i+1))

            while self.players[i].life > 0 and self.computer[i].life > 0:

                self.players[i].life -= self.computer[i].fight
                self.computer[i].life -= self.players[i].fight

                print('%s 向 %s 发起了进攻，%s 剩余血量：%d'% (self.computer[i].name,self.players[i].name,self.players[i].name,self.players[i].life))
                print('%s 向 %s 发起了进攻，%s 剩余血量：%d'% (self.players[i].name,self.computer[i].name,self.computer[i].name,self.computer[i].life))

                if self.players[i].life > 0 and self.computer[i].life <= 0:

                    self.score += 1
                    print('第%s局，你赢啦，敌方输啦！'%(i+1))
                    print('---------------------------------------')
                    input('按回车键继续！')
                    continue
                elif self.players[i].life <= 0 and self.computer[i].life > 0:

                    self.score -= 1
                    print('第%s局，敌方赢啦，你输啦！' % (i + 1))
                    print('---------------------------------------')
                    input('按回车键继续！')
                    continue
                else:
                    print('啊欧，你们俩打了个平手！')
                    print('---------------------------------------')
                    input('按回车键继续！')
                    continue

        input('按回车键，查看最终结局')

    def result_role(self):

        if self.score > 0:
            print('你赢啦！')

        elif self.score < 0:
            print('敌方赢了！')
        else:
            print('打了个平手')

game = game()